package com.foo.web.controller.wechat;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.foo.common.annotation.Log;
import com.foo.common.enums.BusinessType;
import com.foo.wechat.domain.WxCanteenMenu;
import com.foo.wechat.service.IWxCanteenMenuService;
import com.foo.common.core.controller.BaseController;
import com.foo.common.core.domain.AjaxResult;
import com.foo.common.utils.poi.ExcelUtil;
import com.foo.common.core.page.TableDataInfo;

/**
 * 餐厅菜单Controller
 *
 * @author foo
 * @date 2025-11-11
 */
@Controller
@RequestMapping("/wechat/WxCanteenMenu")
public class WxCanteenMenuController extends BaseController
{
    private String prefix = "wechat/WxCanteenMenu";

    @Autowired
    private IWxCanteenMenuService wxCanteenMenuService;

    @RequiresPermissions("wechat:WxCanteenMenu:view")
    @GetMapping()
    public String WxCanteenMenu(String cid, ModelMap mmap)
    {
        mmap.put("cid", cid);
        return prefix + "/WxCanteenMenu";
    }

    /**
     * 查询餐厅菜单列表
     */
    @RequiresPermissions("wechat:WxCanteenMenu:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WxCanteenMenu wxCanteenMenu)
    {
        startPage();
        List<WxCanteenMenu> list = wxCanteenMenuService.selectWxCanteenMenuList(wxCanteenMenu);
        return getDataTable(list);
    }



    /**
     * 新增餐厅菜单
     */
    @GetMapping("/add")
    public String add(String cid, ModelMap mmap)
    {
        mmap.put("cid", cid);
        return prefix + "/add";
    }

    /**
     * 新增保存餐厅菜单
     */
    @RequiresPermissions("wechat:WxCanteenMenu:add")
    @Log(title = "餐厅菜单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WxCanteenMenu wxCanteenMenu)
    {
        return toAjax(wxCanteenMenuService.insertWxCanteenMenu(wxCanteenMenu));
    }

    /**
     * 修改餐厅菜单
     */
    @GetMapping("/edit/{menuId}")
    public String edit(@PathVariable("menuId") Long menuId, ModelMap mmap)
    {
        WxCanteenMenu wxCanteenMenu = wxCanteenMenuService.selectWxCanteenMenuById(menuId);
        mmap.put("wxCanteenMenu", wxCanteenMenu);
        return prefix + "/edit";
    }

    /**
     * 修改保存餐厅菜单
     */
    @RequiresPermissions("wechat:WxCanteenMenu:edit")
    @Log(title = "餐厅菜单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WxCanteenMenu wxCanteenMenu)
    {
        return toAjax(wxCanteenMenuService.updateWxCanteenMenu(wxCanteenMenu));
    }

    /**
     * 删除餐厅菜单
     */
    @RequiresPermissions("wechat:WxCanteenMenu:remove")
    @Log(title = "餐厅菜单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wxCanteenMenuService.deleteWxCanteenMenuByIds(ids));
    }
}
